import React, { useContext } from 'react'
import { Context } from './context'

// #2 Context.Consumer 配合函数消费数据
/* export default function Child2() {
  return (
    <Context.Consumer>
      {(value) => {
        return <div>Child2: {value.age}</div>
      }}
    </Context.Consumer>
  )
} */

export default function Child2() {
  const value = useContext(Context)
  return (
    <div>
      <p>Child2: {value.age}</p>
      <button onClick={value.changeAge}>+1</button>
    </div>
  )
}
